#ifndef DeviceControl_h__
#define DeviceControl_h__
#include "ace/Event_Handler.h"
#include "ace/Time_Value.h"
#include "ace/Reactor.h"
#include "EncoderProfile.h"
#include "../include/proto.h"
#include <ace/INET_Addr.h>
#include "ace/Acceptor.h"
#include <ace/Svc_Handler.h>
#include <ace/SOCK_Stream.h>

class DeviceControl:public ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH>
{
public:
	virtual int open (void *);
	virtual void destroy (void);
	virtual int close (u_long flags = 0){
		ACE_UNUSED_ARG (flags);
		ACE_DEBUG((LM_DEBUG,"call close\n"));
		this->destroy ();
		return 0;
	}
	BYTE *send_data,*left_data;
	int iLeftSize;
	DeviceControl(void){};
	~DeviceControl(void){};
protected:
	void *OnUpgrade(UpgradeRequest *upgradeCmd);
	virtual int handle_input (ACE_HANDLE);
	virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE);
	//virtual int handle_timeout (const ACE_Time_Value &tv,const void *arg){return 0;}
	virtual int handle_close (ACE_HANDLE,ACE_Reactor_Mask){
		printf ("handle_close\n");
		destroy ();return 0;
	}
};


#endif // DeviceControl_h__

